import React from 'react'
import {
	Table,
	Popconfirm
} from 'antd'


export default ({
	list,	
	onSelect,
	onDelete
})=>{
	//列json描述
	const columns=[{
		title:"分类ID",
		dataIndex:"id",
		key:"id"
	},{
		title:"Title",
		dataIndex:"title",
		key:"title"
	},{
		title:"Quantity",
		dataIndex:"quantity",
		key:"quantity"
	},{
		title:"状态",
		render:(text,item)=>{
			if (item.deleted) {return "已完结"} else {return "连载中"}
		},
		key:"deleted"
	},{
		title:"Handle",
		render:(t,item)=>{
			return(
				<React.Fragment>
					<Popconfirm title="Delete?" onConfirm={(evt) => onDelete(item.id)}>
						<a>delete</a>
					</Popconfirm>					
				</React.Fragment>	
			)
		}
	}];
	//行选择
	const rowSelection={
		onChange: (selectedRowKeys, selectedRows) => {    		
    		onSelect(selectedRows)
  		}
	};

	return (
		<Table
			rowSelection={rowSelection}
			dataSource={list}
			columns={columns}
		 />
	)
}